<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var xhr = new XMLHttpRequest();
    // 前端设置是否带cookie
    xhr.withCredentials = true;
    xhr.open('get', 'http://127.0.0.1:8080/?user=luo', true);
    // xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.send();
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            // alert(xhr.responseText);
            var data = xhr.responseText;
            console.log(JSON.parse(data));
        }
    };

</script>

</html>